-
Notifications
You must be signed in to change notification settings - Fork 433
Adding missing features of cosine distribution #2017
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #2017 +/- ##
==========================================
- Coverage 86.36% 86.34% -0.03%
==========================================
Files 146 146
Lines 8788 8807 +19
==========================================
+ Hits 7590 7604 +14
- Misses 1198 1203 +5 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
devmotion
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add tests for the new functionality?
Co-authored-by: David Müller-Widmann <devmotion@users.noreply.github.com>
Co-authored-by: David Müller-Widmann <devmotion@users.noreply.github.com>
Co-authored-by: David Müller-Widmann <devmotion@users.noreply.github.com>
Co-authored-by: David Müller-Widmann <devmotion@users.noreply.github.com>
|
I cleaned I added testing against some known simple values. Some more are needed or is this enough? My code was based on how the rest of cosine.jl looked like. When I saw your corrections the code above started looking suspicious for me and indeed, I'm also not sure about dependencies, but its' easy to change in any case. |
|
@devmotion Could I ask for checking if now it is okay? I am a little unsure about the tests. Is there an instruction somewhere what is the recommended way to write them in Distributions.jl? |
devmotion
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In general, it is unnecessary and usually it is incorrect to precompute any return types.
For testing, IIRC some utilities such as test_mgf or test_affine (?) exists.
|
@devmotion Good to know that such type inference is not useful. I removed the changes related to this. Optionally, maybe something like function pdf(d::Cosine{T}, x::Real) where T<:Real
z = (x - d.μ) / d.σ
y = (1 + cospi(z)) / (2d.σ)
return insupport(d, x) ? y : zero(y)
endcould be considered. I also added application of build-in functions to test affine transformations and cgf. |
This is a very straightforward PR. It adds missing
mgf,cgf,cfand direct affine transformations for theCosinedistribution. There are simple formulas for these, so there is no reason not to include them.One thing which might require attention is if I protect from dividing by 0 correctly.